<?php TPL::output('admin/global/header.tpl.htm'); ?>

<!--left-->
<?php TPL::output('admin/global/left.tpl.htm'); ?>
<!--left-->

<!-- main -->
<div id="main-content">
	<div class="clear"></div>
	<div class="content-box">
		<div class="content-box-header">
			<h3>会员列表</h3>
			<ul class="content-box-tabs">
				<li><a href="#tab1" class="default-tab current">会员列表</a></li>
				<li><a href="#tab2" class="">搜索</a></li>
			</ul>
			<div class="clear"></div>
		</div>
		<div class="content-box-content">
			<div class="tab-content default-tab" id="tab1">
			
				<?php if ($_GET['action'] == 'search') { ?>
					<div style="margin-bottom:5px; padding:3px; height:28px;">共有 <?php echo intval($this->total_rows); ?> 个符合条件的用户。
						<div style="float:right; margin-right:10px;">
							<form id="search_save" action="<?php echo $this->search_url; ?>__sort_key-<?php echo $_GET['sort_key']; ?>__order-<?php echo $_GET['order']; ?>" method="post"><input type="hidden" name="action" value="save_users_search"/>保存此用户列表为：<select id="users_search_id" name="users_search_id"><option value="0">新建列表</option><?php foreach($this->users_search_list as $key => $val) { ?><option value="<?php echo $val['id']; ?>"><?php echo $val['name']; ?></option><?php } ?></select>&nbsp;&nbsp;<input type="text" name="name" class="text-input" style="width:130px;"/>&nbsp;&nbsp;<input type="button" onclick="ajax_post($('#search_save'), _form_process);" value="保存" class="button">
							</form>
						</div>
					</div>
				<?php } ?>
				
				<?php if ($this->list) { ?>
				
				<table class="list">
					<thead>
						<tr>
							<th>ID</th>
							<th>头像</th>
							<th><a href="<?php echo $this->search_url; ?>__sort_key-user_name__order-<?php if ($_GET['sort_key'] == 'user_name' && $_GET['order'] == 'DESC') { ?>ASC<?php }else{ ?>DESC<?php } ?>">用户名<?php if ($_GET['sort_key'] == 'user_name') { ?><?php if ($_GET['order'] == 'ASC') { ?><em class="listup">︿</em><?php }else{ ?><em class="listdown">﹀</em><?php } ?><?php } ?></a></th>
							<th><a href="<?php echo $this->search_url; ?>__sort_key-email__order-<?php if ($_GET['sort_key'] == 'email' && $_GET['order'] == 'DESC') { ?>ASC<?php }else{ ?>DESC<?php } ?>">邮箱<?php if ($_GET['sort_key'] == 'email') { ?><?php if ($_GET['order'] == 'ASC') { ?><em class="listup">︿</em><?php }else{ ?><em class="listdown">﹀</em><?php } ?><?php } ?></a></th>
							<th><a href="<?php echo $this->search_url; ?>__sort_key-group_id__order-<?php if ($_GET['sort_key'] == 'group_id' && $_GET['order'] == 'DESC') { ?>ASC<?php }else{ ?>DESC<?php } ?>">用户组<?php if ($_GET['sort_key'] == 'group_id') { ?><?php if ($_GET['order'] == 'ASC') { ?><em class="listup">︿</em><?php }else{ ?><em class="listdown">﹀</em><?php } ?><?php } ?></a></th>
							<th><a href="<?php echo $this->search_url; ?>__sort_key-reg_time__order-<?php if ($_GET['sort_key'] == 'reg_time' && $_GET['order'] == 'DESC') { ?>ASC<?php }else{ ?>DESC<?php } ?>">注册时间<?php if ($_GET['sort_key'] == 'reg_time') { ?><?php if ($_GET['order'] == 'ASC') { ?><em class="listup">︿</em><?php }else{ ?><em class="listdown">﹀</em><?php } ?><?php } ?></a></th>
							<th><a href="<?php echo $this->search_url; ?>__sort_key-last_active__order-<?php if ($_GET['sort_key'] == 'last_active' && $_GET['order'] == 'DESC') { ?>ASC<?php }else{ ?>DESC<?php } ?>">最近活跃时间<?php if ($_GET['sort_key'] == 'last_active') { ?><?php if ($_GET['order'] == 'ASC') { ?><em class="listup">︿</em><?php }else{ ?><em class="listdown">﹀</em><?php } ?><?php } ?></a></th>
							<th><a href="<?php echo $this->search_url; ?>__sort_key-online_time__order-<?php if ($_GET['sort_key'] == 'online_time' && $_GET['order'] == 'DESC') { ?>ASC<?php }else{ ?>DESC<?php } ?>">在线(min)<?php if ($_GET['sort_key'] == 'online_time') { ?><?php if ($_GET['order'] == 'ASC') { ?><em class="listup">︿</em><?php }else{ ?><em class="listdown">﹀</em><?php } ?><?php } ?></a></th>
							<th><a href="<?php echo $this->search_url; ?>__sort_key-reputation__order-<?php if ($_GET['sort_key'] == 'reputation' && $_GET['order'] == 'DESC') { ?>ASC<?php }else{ ?>DESC<?php } ?>">威望<?php if ($_GET['sort_key'] == 'reputation') { ?><?php if ($_GET['order'] == 'ASC') { ?><em class="listup">︿</em><?php }else{ ?><em class="listdown">﹀</em><?php } ?><?php } ?></a></th>
							<?php if (get_setting('integral_system_enabled') == 'Y') { ?>
								<th><a href="<?php echo $this->search_url; ?>__sort_key-integral__order-<?php if ($_GET['sort_key'] == 'integral' && $_GET['order'] == 'DESC') { ?>ASC<?php }else{ ?>DESC<?php } ?>">积分<?php if ($_GET['sort_key'] == 'integral') { ?><?php if ($_GET['order'] == 'ASC') { ?><em class="listup">︿</em><?php }else{ ?><em class="listdown">﹀</em><?php } ?><?php } ?></a></th>
							<?php } ?>
							<th>操作</th>
						</tr>
					</thead>
					<tbody style="border-bottom: 1px solid #ddd;">
						<?php foreach ($this->list AS $key => $val) { ?>
						<tr>
							<td><?php echo $val['uid']; ?></td>
							<td align="center"><div align="center"><img style="vertical-align: middle;" src="<?php echo get_avatar_url($val['uid'], 'min'); ?>"/></div></td>
							<td><a href="people/<?php echo $val['url_token']; ?>" target="_blank" title="title"><?php echo $val['user_name']; ?></a>
								<?php if ($val['forbidden']) { ?>
								&nbsp;<font color="#FF0000">[禁止]</font>
								<?php }else if (!$val['valid_email']) { ?>
								&nbsp;<font color="#FF0000">[未验证]</font>
								<?php } ?></td>
							<td><?php echo $val['email']; ?></td>
							<td><?php echo $this->system_group[$val['group_id']]['group_name']; ?></td>
							<td><?php echo date("Y-m-d H:i:s", $val['reg_time']); ?></td>
							<td><?php if ($val['last_active']) { ?><?php echo date("Y-m-d H:i:s", $val['last_active']); ?><?php } ?></td>
							<td><?php echo round($val['online_time']/60); ?></td>
							<td><?php echo $val['reputation']; ?></td>
							<?php if (get_setting('integral_system_enabled') == 'Y') { ?>
								<td><?php echo $val['integral']; ?></td>
							<?php } ?>
							<td><a href="admin/user_manage/edit/uid-<?php echo $val['uid']; ?>" title="修改"><img src="<?php echo G_STATIC_URL;?>/admin/images/icons/pencil.png"/></a><?php if ($val['uid'] != $this->user_id) { ?> &nbsp; <a href="javascript:;" onClick="ajax_request(G_BASE_URL + '/admin/user_manage/forbidden_status_ajax/user_id-<?php echo $val['uid']; ?>__status-<?php echo intval($val['forbidden']) ? 0 : 1; ?>');" title="<?php if ($val['forbidden']) { ?>解除禁止<?php }else{ ?>禁止用户<?php } ?>"><img src="<?php echo G_STATIC_URL;?>/admin/images/icons/<?php if ($val['forbidden']) { ?>lock<?php }else{ ?>unlock<?php } ?>.png"/></a><?php } ?></td>
						</tr>
						<?php } ?>
					</tbody>
					<tfoot>
						<tr>
							<td colspan="<?php if (get_setting('integral_system_enabled') == 'Y') { ?>11<?php }else{ ?>10<?php } ?>"><div class="pagination"> <?php echo $this->pagination; ?> </div>
								<div class="clear"></div></td>
						</tr>
					</tfoot>
				</table>
				<?php } ?>
			</div>
			
			<div class="tab-content" id="tab2" style="display:none;">
				<div style=" float:left; width:35%;">
				<form method="post" action="admin/user_manage/list/" onsubmit="return false;" id="search_form">
				<input name="action" type="hidden" value="search"/>
				<p>
					<label> 用户名：</label>
					<input type="text" value="<?php echo rawurldecode($_GET['user_name']); ?>" name="user_name" class="text-input normal-input" />
				</p>
				<p>
					<label> 邮箱：</label>
					<input type="text" value="<?php echo rawurldecode($_GET['email']); ?>" name="email" class="text-input normal-input" />
				</p>
				<?php if (!$_GET['action']) { ?>
				<p><a href="javascript:;" onclick="$(this).parent().next().show();$(this).parent().remove();"><b>更多搜索<em style="display: inline-block; font-size: 12px; width: 15px; vertical-align: top; margin-top: 6px; height: 12px; line-height: 12px;">﹀</em></b></a></p>
				<?php } ?>
				<div style="display:<?php if ($_GET['action'] == 'search') { ?>block<?php }else{ ?>none<?php } ?>;">
				<p>
					<label> 注册时间：</label>
					<input type="text" value="<?php echo base64_decode($_GET['reg_date']); ?>" name="reg_date" class="text-input date_picker" style="width:150px;" />
				</p>
				<p>
					<label> 用户组：</label>
					<select name="group_id" style="float:left; width:200px;">
						<option value=""></option>
						<?php foreach($this->system_group as $skey => $sval) { ?>
							<option value="<?php echo $sval['group_id']; ?>"<?php if ($_GET['group_id'] == $sval['group_id']) { ?> selected=true<?php } ?>><?php echo $sval['group_name']; ?></option>
						<?php } ?>
					</select>
				</p>
				<p style="clear:both;"></p>
				<p>
					<label> 最后登陆时间：</label>
					<input type="text" value="<?php echo base64_decode($_GET['last_login_date']); ?>" name="last_login_date" class="text-input date_picker" style="width:150px;" />
				</p>
				<p>
					<label> 最后登陆IP段 ( 限C段，例如： 203.31.42.* )：</label>
					<input type="text" value="<?php echo $_GET['ip']; ?>" name="ip" class="text-input normal-input" />
				</p>
				<p>
					<label> 积分：</label>
					<input type="text" name="integral_min" value="<?php echo $_GET['integral_min']; ?>" class="text-input" style="width:40px;" /> - <input type="text" name="integral_max" value="<?php echo $_GET['integral_max']; ?>" class="text-input" style="width:40px;" />
				</p>
				<p>
					<label> 威望：</label>
					<input type="text" name="reputation_min" value="<?php echo $_GET['reputation_min']; ?>" class="text-input" style="width:40px;" /> - <input type="text" name="reputation_max" value="<?php echo $_GET['reputation_max']; ?>" class="text-input" style="width:40px;" />
				</p>
				<p>
					<label> 回复数：</label>
					<input type="text" name="answer_count_min" value="<?php echo $_GET['answer_count_min']; ?>" class="text-input" style="width:40px;" /> - <input type="text" name="answer_count_max" value="<?php echo $_GET['answer_count_max']; ?>" class="text-input" style="width:40px;" />
				</p>
				<p>
					<label> 职业：</label>
					<select name="job_id" style="float:left; width:200px;">
						<option value="0"></option>
						<?php foreach($this->job_list as $job_id => $job_name) { ?>
							<option value="<?php echo $job_id; ?>"<?php if ($_GET['job_id'] == $job_id) { ?> selected=true<?php } ?>><?php echo $job_name; ?></option>
						<?php } ?>
					</select>
				</p>
				<p style="clear:both;">
					<label> 居住地：</label>
					<select name="province" class="select_area" style="float:left;"></select>
					<select name="city" class="select_area" style="float:left; margin-left:10px;"></select>
				</p>
				<p>
					<label style="clear:both;"> 生日：</label>
					<input type="text" value="<?php echo base64_decode($_GET['birthday']); ?>" name="birthday" class="text-input date_picker" style="width:150px;" />
				</p>
				<p>
					<label> 用户签名：</label>
					<input type="text" value="<?php echo rawurldecode($_GET['signature']); ?>" name="signature" class="text-input normal-input" />
				</p>
				<p>
					<label> 常用邮箱：</label>
					<input type="text" value="<?php echo $_GET['common_email']; ?>" name="common_email" class="text-input normal-input" />
				</p>
				<p>
					<label> 手机号：</label>
					<input type="text" value="<?php echo $_GET['mobile']; ?>" name="mobile" class="text-input normal-input" />
				</p>
				<p>
					<label> QQ号：</label>
					<input type="text" value="<?php echo $_GET['qq']; ?>" name="qq" class="text-input normal-input" />
				</p>
				<p>
					<label> 网站：</label>
					<input type="text" value="<?php echo $_GET['homepage']; ?>" name="homepage" class="text-input normal-input" />
				</p>
				<p>
					<label> 学校：</label>
					<input type="text" value="<?php echo rawurldecode($_GET['school_name']); ?>" name="school_name" class="text-input normal-input" />
				</p>
				<p>
					<label> 专业（所在院系）：</label>
					<input type="text" value="<?php echo rawurldecode($_GET['departments']); ?>" name="departments" class="text-input normal-input" />
				</p>
				<p>
					<label> 公司：</label>
					<input type="text" value="<?php echo rawurldecode($_GET['company_name']); ?>" name="company_name" class="text-input normal-input" />
				</p>
				<p>
					<label> 职位：</label>
					<input type="text" value="<?php echo $_GET['company_job_id']; ?>" name="company_job_id" class="text-input normal-input" />
				</p>
				</div>
				<p style="clear:both;">
					<input type="button" onclick="ajax_post($('#search_form'), _form_process);" value="搜  索" class="button">
				</p>
				</form>
				</div>
				
				<?php if ($this->users_search_list) { ?>
					<div style="float:left; width:250px;">搜索历史：
					<ul>
						<?php foreach($this->users_search_list as $val) { ?>
						<li><a href="admin/user_manage/list/action-search__<?php echo $val['search_param']; ?>"><?php echo $val['name']; ?></a>&nbsp;<a href="javascript:;" onclick="delete_users_search($(this), <?php echo $val['id']; ?>);">[x]</a></li>
						<?php } ?>
					</ul>
					</div>
				<?php } ?>
				
			</div>
			
		</div>
		<div class="clear"></div>
		<div id="notf_tip" style="display:none;" class="notification png_bg"> <a href="javascript:;" class="close"><img src="<?php echo G_STATIC_URL;?>/admin/images/icons/cross_grey_small.png" alt="关闭" /></a>
			<div id="notf_cont"></div>
		</div>
	</div>

<!-- footer -->
<?php TPL::output('admin/global/footer.tpl.htm'); ?>
<!-- footer -->

</div>
<!-- main -->

</div>

<script type="text/javascript">
$(document).ready(function () {
	$('.select_area').LocationSelect({
        labels: ["请选择省份或直辖市", "请选择城市"],
        elements: document.getElementsByTagName("select"),
        detector: function () {
            this.select(["<?php echo $_GET['province']; ?>", "<?php echo $_GET['city']; ?>"]);
        },
		dataUrl: G_BASE_URL + '/account/ajax/areas_json_data/'
    });
	
	$('#users_search_id').change(function ()
	{
		if ($(this).val() == 0)
		{
			$('#search_save input[name=name]').show();
		}
		else
		{
			$('#search_save input[name=name]').hide();
		}
	});
});

function delete_users_search(el, id)
{
	el.parent().remove();
	$.post(G_BASE_URL + '/admin/user_manage/delete_users_search/', 'id=' + id);
}
</script>

</body>
</html>